<template>
<div style="font-size: 12px; line-height: 60px;display: flex">
  <div style="flex: 1;font-size: 18px">
    <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>
  </div>
  <div style="flex: 1;font-size: 18px"><h1 style="color: #0c0c0b">智慧社区管理平台</h1></div>
  <el-dropdown style="width: 100px; cursor: pointer">
    <div>
   <img src="../img/1.jpg" style="width: 30px;height: 30px;border-radius: 50%;position: relative;top: 10px;right: 5px">
      <span>{{user.username}}<i class="el-icon-s-custom" style="margin-left: 5px"></i></span>
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item>
        <router-link to="/person" style="text-decoration: none" >个人信息</router-link>
        </el-dropdown-item>
      <el-dropdown-item>
<!--        <router-link to="/login" style="text-decoration: none" >退出</router-link>-->
        <span style="text-decoration: none" @click="loginout">退出</span>
        </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</div>
</template>

<script>
export default {
  name: "Header",
  props:{
    collapseBtnClass: String,
    collapse: Boolean
  },
  data(){
    return{
      user:localStorage.getItem("user")?JSON.parse(localStorage.getItem("user")):"登录"
    }
  },
  methods:{
    loginout(){
this.$router.push("/login")
      localStorage.removeItem("user")
      this.$message.success("退出成功!")
    }
  }
}
</script>

<style scoped>
.bg{

}
</style>